'''
任意节点的子树的高度差都小于等于1
'''
class Solution:
    res = True
    def IsBalancedSolution(self,pRoot):
        # write code here
        self.helper(pRoot)
        return self.res
    def helper(self,root):
        if not root:
            return True
        if not self.res:
            return False
        left = 1 + self.helper(root.left)
        right = 1 + self.helper(root.right)
        if abs(left-right)>1:
            self.res = False
        # 递归的求出来, 因为提前终止就return True了
        return max(left,right)